package com.wangce.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wangce.dao.OrderDao;
import com.wangce.entity.*;
import com.wangce.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClassName: OrderServiceImpl
 * Description:
 * date: 2021/12/3 10:21
 *
 * @author 凡人
 * @since JDK 1.8
 */
@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    OrderDao orderDao;

    /**
     * 出库列表
     * @param d
     * @param cur
     * @param size
     * @return
     */
    @Override
    public PageInfo<Order> list(Dim d, Integer cur, Integer size) {
        PageHelper.startPage(cur,size);
        return new PageInfo<Order>(orderDao.list(d));
    }

    /**
     * 获取菜单
     * @return
     */
    @Override
    public List<Menu> getTree() {
        Integer pid = 0;
        return orderDao.getTree(pid);
    }

    /**
     * 登陆
     * @param u
     * @return
     */
    @Override
    public User login(User u) {
        return orderDao.login(u);
    }

    @Override
    public Integer add(Order o) {
        Integer i = orderDao.add(o);
        i+= orderDao.addOdetail(o.getLists(),o.getId());
        return i;
    }

    @Override
    public Integer addSend(Send s) {
        Integer i = orderDao.addSend(s);
        i+= orderDao.addSendDetail(s.getLists(),s.getId());
        return i;
    }
}
